﻿@inherits IQToolkitCodeGen.Template.EntityTemplate
@using IQToolkitCodeGen.Model;
@using System.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Services;
using System.Data.Services.Common;

@if(this.Table.HasPrimaryKey()) {
@:using System.ComponentModel.DataAnnotations;
}

namespace @this.Namespace {
        @if (this.Table.Columns != null && this.Table.Columns.Count > 0) {
            string[] primaryKeys = this.Table.Columns.Where(c => c.PrimaryKey).Select(c => c.PropertyName).ToArray();

            if (primaryKeys.Length > 0) {
    @:[DataServiceKey("@string.Join("\",\"", primaryKeys)")]
            }
        }
    [Serializable]
    public partial class @this.Singularize(this.Table.EntityName) {
		@foreach (Column column in this.Table.Columns) {
      if (column.ShouldInclude() && !string.IsNullOrEmpty(column.PropertyType)) {
        @:public @column.PropertyType @column.PropertyName { get; set; }
            }
  }
		@{foreach (Association association in this.Table.Associations) {
        if (association.ShouldInclude()) {
            if (association.AssociationType == AssociationType.List) {
        @:public IList<@association.RelatedEntityName> @association.PropertyName { get; set; }
                }
            else {
        @:public @association.RelatedEntityName @association.PropertyName { get; set; }				
                }
            }
            else{
        @://public @association.RelatedEntityName @association.PropertyName { get; set; }
        @://KeyMembers: @association.KeyMembers RelatedTableName: @association.RelatedTableName RelatedKeyMembers: @association.RelatedKeyMembers
        }
        }
	}
    }
}